package cn.com.connext.scrm.repository.master;

import cn.com.connext.scrm.domain.master.BrowseRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface BrowseRecordRepository extends JpaRepository<BrowseRecord, String>, JpaSpecificationExecutor {

    @Query(value = "select count(a) from BrowseRecord a where a.noteId = :noteId")
    Integer countAllByNoteId(@Param("noteId") String noteId);

    @Query(value = "select note_id as noteId,count(0) as counts from browse_record group by note_id", nativeQuery = true)
    List<Object[]> countAll();
}
